<?php  
class ControllerAlbumAlbum extends Controller {
	public function index() {
		$this->document->setTitle($this->config->get('config_title'));
		$this->document->setDescription($this->config->get('config_meta_description'));
		
		$this->document->addScript('catalog/view/javascript/module/album/bootstrap.js');

		$this->data['heading_title'] = $this->config->get('config_title');
		
		$this->load->model('album/album');
		$this->load->model('tool/image');
		
		$albums = $this->model_album_album->getAlbums();
		
		$this->data['albums'] = array();
		foreach ($albums as $album){
			if ($album['image']) {
				$image = $this->model_tool_image->resize($album['image'], 980, 500);
			} else {
				$image = false;
			}
			
			$this->data['albums'][] = array(
				'id' => $album['album_id'],
				'name' => $album['name'],
				'href' => $this->url->link('album/detail', 'album_id=' . $album['album_id']),
				'image' => $image
			);
		}
		
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/album/album.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/album/album.tpl';
		} else {
			$this->template = 'default/template/album/album.tpl';
		}
		
		$this->children = array(
			'common/footer',
			'common/header'
		);
										
		$this->response->setOutput($this->render());
	}
}
?>